package com.babel.util.lide;

import java.io.UnsupportedEncodingException;

import org.apache.commons.httpclient.Header;


/**
 * 功能：Http返回对象的封装
 *  详细：封装Http返回信息
 * @author lyj
 * @date 2017年5月10日---下午5:44:00
 */
public class HttpResponse {

    /**
     * 返回中的Header信息
     */
    private Header[] responseHeaders;

    /**
     * String类型的result
     */
    private String stringResult;

    /**
     * btye类型的result
     */
    private byte[] byteResult;

    public Header[] getResponseHeaders() {
	return responseHeaders;
    }

    public void setResponseHeaders(Header[] responseHeaders) {
	this.responseHeaders = responseHeaders;
    }

    public byte[] getByteResult() {
	if (byteResult != null) {
	    return byteResult;
	}
	if (stringResult != null) {
	    return stringResult.getBytes();
	}
	return null;
    }

    public void setByteResult(byte[] byteResult) {
	this.byteResult = byteResult;
    }

    public String getStringResult() throws UnsupportedEncodingException {
	if (stringResult != null) {
	    return stringResult;
	}
	if (byteResult != null) {
	    return new String(byteResult, LeadbankConfig.input_charset);
	}
	return null;
    }

    public void setStringResult(String stringResult) {
	this.stringResult = stringResult;
    }

}
